<?php

declare(strict_types=1);

namespace App\Model\PssModel;

use App\Model\BaseModel\BasePssModel;
use App\Service\Code\Normal;
class OrderReturnLog extends BasePssModel
{
    public $table = 'order_return_log';
    //1-申请售后，2-取消售后，3-审核通过，4-审核拒绝，5，审核操作退款
    const AFTER_APPLY           = 1;
    const AFTER_CANCEL          = 2;
    const AFTER_PASS            = 3;
    const AFTER_REJECT          = 4;
    const AFTER_RETURN_MONEY    = 5;
    
    /**
     * 写入售后订单日志数据
     * @param array $param
     */
    public function addLog( $param = [] )
    {
        if( empty($param['order_id']) ) {
            return Normal::returnCode(Normal::SUC,"except param order_id");
        }
        
        if( empty($param['type']) ) {
            return Normal::returnCode(Normal::SUC,"except param type");
        }
        
        if( empty($param['contents']) ) {
            return Normal::returnCode(Normal::SUC,"except param contents");
        }
        
        if( empty($param['system_user_id']) ) {
            return Normal::returnCode(Normal::SUC,"except param system_user_id");
        }
        
        if( empty($param['system_user_name']) ) {
            return Normal::returnCode(Normal::SUC,"except param system_user_name");
        }
        
        $data = [
            'order_id'          =>  $param['order_id'],
            'type'              =>  $param['type'],
            'contents'          =>  $param['contents'],
            'system_user_id'    =>  $param['system_user_id'],
            'system_user_name'  =>  $param['system_user_name'],
            'cd'                =>  time()
        ];
    
        if( $this->add($data) ) {
            return Normal::returnCode(Normal::SUC,"写入订单日志数据成功");
        }
    
        return Normal::returnCode(Normal::FAIL,"写入订单日志数据失败");
    }
}
